package com.woniuxy.commons.service;

import com.itextpdf.text.DocumentException;
import com.woniuxy.commons.dto.ExamDto;
import com.woniuxy.commons.dto.PaperDto;
import com.woniuxy.commons.entity.Exam;
import com.woniuxy.commons.entity.Paper;
import com.woniuxy.commons.entity.PaperStructure;
import com.woniuxy.commons.entity.ResponseEntity;
import com.woniuxy.commons.factory.RemoteExamServiceFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @author 吴毛伟
 * @date:2020/7/28 10:38
 * @description:
 */
@FeignClient(name = "EXAM", fallbackFactory = RemoteExamServiceFactory.class)
public interface RemoteExamService {
    /**
     * @date:10:39 2020/7/28
     * @description:通过ID查看考试
     * @params:
     * @return:
     * @author 吴毛伟
     */
    @GetMapping("/paper/find/{id}")
    public Exam findById(@PathVariable("id") int id);

    /**
     * @date:10:48 2020/7/28
     * @description:通过ID获取试卷
     * @params:
     * @return:
     * @author 吴毛伟
     */
    @RequestMapping("/paper/find/{paperId}")
    public ResponseEntity<Paper> findPaperByPaperId(@PathVariable("paperId") int paperId);

    /**
     * @date:10:40 2020/7/28
     * @description:通过试卷id获取相应的试卷结构
     * @params:
     * @return:
     * @author 吴毛伟
     */
    @GetMapping("/paper/getStructure/{paperId}")
    public ResponseEntity<PaperStructure> findPaperStructureByPaperId(@PathVariable("paperId") int paperId);

    /**
     * @date:10:42 2020/7/28
     * @description:打印試卷
     * @params:
     * @return:
     * @author 吴毛伟
     */
    @GetMapping("/paper/printPaper/{paperId}")
    public ResponseEntity<String> printPaper(@PathVariable("paperId") int paperId) throws IOException, DocumentException;

    /**
     * @date:10:03 2020/7/29
     * @description:试卷查看
     * @params:
     * @return:
     * @author 吴毛伟
     */
    @GetMapping("/paper/fullPaper/{paperId}")
    public ResponseEntity<PaperDto> getFullPaper(@PathVariable("paperId") int paperId);
    
    /*
    *
     * @Description: 多条件分页查询考试
     * @Param: [examDto]
     * @return: com.woniuxy.commons.entity.ResponseEntity
     * @Author: 王敞
     * @Date: 19:44 2020/8/3
     **/
    @PostMapping("/exam/caps")
    public ResponseEntity conditionAndPageSearch(@RequestBody ExamDto examDto);

    /*
    *
     * @Description: 学习地图板块用，查询考试
     * @Param: [exam]
     * @return: com.woniuxy.commons.entity.Exam
     * @Author: 王敞
     * @Date: 21:12 2020/8/3
     **/
    @PostMapping("/exam/findExamById")
    public Exam findExamById(@RequestBody Exam exam);
}
